package com.cskaoyan.service;

import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.UserMapper;
import com.cskaoyan.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author stone
 * @date 2022/11/12 14:35
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    UserMapper userMapper;

    @Override
    public void insertUser(User user) {
        //SqlSession sqlSession = MyBatisUtil.getSqlSession();
        //UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        //userMapper.insert(user);
        //sqlSession.commit();
        //sqlSession.close();
        userMapper.insert(user); // 整合完成之后，事务会自动提交，每执行一行，就提交一行
    }
}
